<template>
  <div class="app-container">
    <div v-for="item in historyList" :key="item.id">
      <postItem :post="item" />
    </div>
  </div>
</template>
<script>
import invitationApi from '@/api/invitation'
import postItem from '@/components/postItem';
export default {
  components: {
    postItem
  },
  data() {
    return {
      role: this.$store.getters.roles,
      historyList: null,
      historyPage: {
        hpage: 1,
        hlimit: 5,
        htotal: 0
      }
    }
  },

  created() {
    this.historyPage = {
      hpage: 1,
      hlimit: 5,
      htotal: 0
    }
  },
  mounted() {
    this.getHistory();
  },
  methods: {
    getHistory() {
      const page = this.historyPage.hpage
      const limit = this.historyPage.hlimit
      invitationApi.show(page, limit)
        .then(response => {
          this.historyList = response.data.item
          this.historyPage.atotal = response.data.total
        })
        .catch(() => {
        })
    },
    // 分页
    handleCurrentChange(val) {
      this.historyPage.hpage = val
      this.getHistory()
    },
    handleSizeChange(val) {
      this.historyPage.hlimit = val
      this.historyPage.hpage = 1
      this.getHistory()
    },
  }
}
</script>
